import type { UpdateTaskParams, ProjectTask } from '@/types/project';
import type { CommonResult } from '@/types/global';
import { http } from '@/utils/http';

// 接口前缀
const API_PREFIX = '/shopmanager/mobile';

/**
 * 获取项目任务列表
 * @param projectId 项目ID
 * @returns 任务列表
 */
export const getListByProjectAPI = (projectId: number) => {
	return http<ProjectTask[]>({
		url: `${API_PREFIX}/tasks/getListByProject/${projectId}`,
		method: 'GET'
	});
};

/**
 * 获取任务详情
 * @param id 任务ID
 * @returns 任务详细信息
 */
export const getDetailAPI = (id: number) => {
	return http<ProjectTask>({
		url: `${API_PREFIX}/tasks/getDetail/${id}`,
		method: 'GET'
	});
};

/**
 * 更新任务
 * @param params 更新参数
 * @returns 更新结果
 */
export const updateTaskAPI = (params: UpdateTaskParams) => {
	return http<CommonResult>({
		url: `${API_PREFIX}/tasks/update`,
		method: 'POST',
		data: params
	});
};
